package vnu.edu;

import jade.content.onto.BasicOntology;
import jade.content.onto.Ontology;
import jade.content.onto.OntologyException;
import jade.content.schema.AgentActionSchema;
import jade.content.schema.ConceptSchema;
import jade.content.schema.ObjectSchema;
import jade.content.schema.PrimitiveSchema;
import jade.content.schema.TermSchema;
import vnu.edu.vocabulary.NewsVocabulary;

import com.tilab.wsig.examples.AgentInfo;

public class NewsOntology extends Ontology implements NewsVocabulary {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private final static Ontology theInstance = new NewsOntology();

	public final static Ontology getInstance() {
		return theInstance;
	}

	public NewsOntology() {
		super(ONTOLOGY_NAME_NEWS_MAKER, BasicOntology.getInstance());
		try {
			add(new ConceptSchema(AGENTINFO), AgentInfo.class);
			add(new AgentActionSchema(NEWS_MAKER), NewsMaker.class);
			add(new ConceptSchema(NEWSELEMENT), NewsElement.class);
			add(new AgentActionSchema(UPDATE_NEWS), UpdateNews.class);
			add(new AgentActionSchema(INSET_REQUEST_INFORMATION),
					InsertRequestedInformationAction.class);

			ConceptSchema cs = (ConceptSchema) getSchema(NEWSELEMENT);
			cs.add(TITLE, (PrimitiveSchema) getSchema(BasicOntology.STRING));
			cs.add(DESCRIPTION,
					(PrimitiveSchema) getSchema(BasicOntology.STRING));
			cs.add(LINK, (PrimitiveSchema) getSchema(BasicOntology.STRING));

			cs = (ConceptSchema) getSchema(AGENTINFO);
			cs.add(AGENTAID, (TermSchema) getSchema(BasicOntology.AID));
			cs.add(STARTDATE, (PrimitiveSchema) getSchema(BasicOntology.DATE));

			AgentActionSchema as = (AgentActionSchema) getSchema(NEWS_MAKER);
			as.add(NAME_ELEMENT,
					(PrimitiveSchema) getSchema(BasicOntology.STRING));
			as.add(SPORT_PRIORITY,
					(PrimitiveSchema) getSchema(BasicOntology.FLOAT));
			as.add(TECHNOLOGY_PRIORITY,
					(PrimitiveSchema) getSchema(BasicOntology.FLOAT));
			as.setResult((ConceptSchema) getSchema(NEWSELEMENT), 0,
					ObjectSchema.UNLIMITED);

			as = (AgentActionSchema) getSchema(UPDATE_NEWS);
			as.add(FROM_DATE, (PrimitiveSchema) getSchema(BasicOntology.DATE));

			as = (AgentActionSchema) getSchema(INSET_REQUEST_INFORMATION);
			as.add(USER_NAME, (PrimitiveSchema) getSchema(BasicOntology.STRING));

		} catch (OntologyException oe) {
			// TODO: handle exception
			oe.printStackTrace();
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

}
